/*
 * kjssar.c
 * KJ's simplified stream archiver (kjssar)
 * 
 * (C)Copyright 2013-2015 by Klaus-J. Wolf, kj (at) seismic (dot) de
 * This file is licensed under the General Public License Version 2.
 * http://www.gnu.org/licenses/gpl-2.0.html
 * 
 * This is a proof-of-concept implementation.
 * 
 */


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "kjgetopt.h"


enum { OPT_HELP, OPT_VERSION, OPT_CREATE, OPT_EXTRACT, OPT_TYPE, OPT_APPEND,
       OPT_VERBOSE,
       OPT_KEEP, OPT_UPDATE, OPT_UNICODE, OPT_SORT, OPT_COMPRESS, OPT_FORMAT,
       OPT_ATTR, OPT_MTREE
};


static struct CLOption options[] = {
    { OPT_HELP, 0, 0, 0, "help", "display help" },
    { OPT_VERSION, 0, 0, 'V', "version", "display version" },
    { OPT_CREATE, 0, 0, 'c', "create", "(cmd) create archive" },
    { OPT_EXTRACT, 0, 0, 'x', "extract", "(cmd) extract archive" },
    { OPT_TYPE, 0, 0, 't', "list", "(cmd) list archive" },
    { OPT_APPEND, 0, 0, 'a', "append", "(cmd) append to archive" },
    { OPT_VERBOSE, 0, 0, 'v', "verbose", "increase verbosity" },
    { OPT_KEEP, 0, 0, 'k', "keep", "keep existing files" },
    { OPT_UPDATE, 0, 0, 'u', "update", "overwrite existing files if newer" },
    { OPT_UNICODE, 0, 0, 'U', "unicode", "use unicode (different behaviour when creating vs. extracting!)" },
    { OPT_SORT, 0, 0, 'S', "sort", "sort by extension (when creating an archive to allow for better compression)" },
    { OPT_COMPRESS, 1, 0, 'X', "compressor", "set input/output compression program" },
    { OPT_FORMAT, 1, 0, 'T', "set output format" },
    { OPT_ATTR, 1, 1, 'O', "specify attributes on extraction" },
    { OPT_MTREE, 0, 0, 'M', "mtree(8) mode (changes general behaviour!)" }
};


static const char *extrahelp =
    "Extraction Attributes:\n"
    "\t\t'u' set uid by number / 'U' set uid by name\n"
    "\t\t'g' set gid by number / 'G' set gid by name\n"
    "\t\t's' setuid/setgid/sticky ok\n"
    "\t\t'a' absolute symlinks / 'r' relative symlinks\n"
    "\t\t'c','b' character, block devices\n"
    "\t\t'S','F' sockets, fifos\n"
    "\t\t'A' absolute files\n"
    "\n"
    "\tdefault for root: 'UGsacbSF'\n"
    "\tdefault for user: 'rSF'\n";

/*
# TODO return error level on I/O errors
# TODO if ACLs are present, attach U/G list
# TODO primary commands as normal options
# TODO sparse files, hardlinks
# TODO -F files from...
# TODO typical : UID/GID by name, if not resolvable, $uid/$gid (user) or UID/GID by number (root)
# TODO extraction in mtree mode
# TODO no-overwrite
*/


#ifdef MAIN

int main(int argc, char *argv[])
{
    kjdisplayhelp(options, SIZE(options), stdout);
    return 0;
}

#endif

